<%@ Language=VBScript%>
<!--#include file="..\getFormName.inc"-->
<%	
	'on error Resume next
	set Conn=server.CreateObject("ADODB.Connection")
	Conn.Open Application("StrConn")
	if Err.number then
		Set Conn=nothing
		Response.Redirect("..\Error.asp?ErrorCode=2")
	end if
	'Set Conn=Server.CreateObject("ADODB.Connection")
	'Conn.Open Application("StrConn")
	bComm=request("bComm")
	Dim ten
	bPassword=request("password")	
	if bComm="login" then
		bUsername=request("username")
		bPassword=request("password")							
		set RecKT=server.CreateObject("ADODB.recordset")
		ssql="Select macanbo,username,password,Loai,Lock from canbo where username like '"& replace(bUsername,"'","''") &"' and password like '"& bPassword &"'"
		RecKT.CursorType=3
		RecKT.CacheSize=5
		recKT.Open ssql,Conn
		if recKT.RecordCount>0 then		
			if RecKT("Lock")=TRUE then
				Session("Started")="no"
				msg="Ng­ười sử dụng này tạm thời bị khoá. Hãy liên hệ với người quản trị văn thư !"
				color="red"
			else
				Session("Started")="yes"
				Session("Uname")=RecKT("username")
				Session("Pass")=RecKT("Password")
				Session("bMaCB")=RecKT("macanbo")
			end if	
		else
			Session("Started")="no"
			msg="Sai m&#7853;t kh&#7849;u m&#7901;i b&#7841;n g&#245; l&#7841;i !"
			color="red"			
		end if
	end if
	if bComm="restart" then
		Session("Permision") =""
		Session("Started")="no"
		Session("Uname")=""
		Session("Pass")=""
		Session("bMaCB")=""
		msg="Mời bạn gõ tên và mật khẩu truy nhập !"
		color="blue"
	end if
%>

<SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>
<!--
function Cancel_onclick() {
	<%if Session("Started")="no" then %>
		Login.Username.focus()
	<%end if%>
}
function window_onload() {

}

//-->
</SCRIPT>
<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
</Head>
<LINK href="../styles/styles.css" type=text/css rel=STYLESHEET>
<BODY style="font-family:arial" Topmargin=0 bgcolor="white" LANGUAGE=javascript onload="return window_onload()">
<base target="main" >
<% if Session("Started")="no" then%>
<P>&nbsp;</P>
<P>&nbsp;</P>
<P>&nbsp;</P>
<P>&nbsp;</P>
<P>&nbsp;</P>
<form method="post" action="../leftmain.asp?bComm=login" name="Login" target="_parent" >
  <div align="center">
    <center>
    <p><font size=3 color=<%=color%>><%=msg%></font></p>
    <table border="0" width="200" cellspacing="0" cellpadding="4" style="border: solid 1px Gray; background-color: #EEEEEE">
      <tr>
        <td width="50%" colspan="2" style="background-color:Gray; color:White; font-weight:bold; font-size:10pt; text-align:center; padding:6px">
            ĐĂNG NHẬP HỆ THỐNG
        </td>
      </tr>
      <tr>
        <td width="34%" nowrap><font size  ="2">&nbsp;Người sử dụng:</font></td>
        <td width="66%" nowrap><input name="Username" size="20"></td>
      </tr>
      <tr>
        <td width="34%" nowrap><font size  ="2">&nbsp;Mật khẩu:</font></td>
        <td width="66%" nowrap>
        <input type="password" name="Password" size="20" ></td>
      </tr>
      <tr>
        <td width="50%" colspan="2" valign="middle" height="40">
          <p align="center">
			<input type="submit" value="&#208;&#259;ng nh&#7853;p" name="Logon" style="POSITION: relative; WIDTH: 80px">&nbsp;
			<input type="button" value="B&#7887; qua" name="Cancel" style="POSITION: relative; WIDTH: 80px" LANGUAGE=javascript onclick="return Cancel_onclick()">
          </p>
        </td>
      </tr>
    </table>
    </center>
  </div>
</form>
<%else%>
		<table border=0 width="100%">
		<tr>
			<td width="83%" align="center"><font color=blue size=3><b>NSD <i><%=Session("bHoten")%></i><font color=blue size=3>
            đăng nhập thành công.</b></font></td>
			<%if Session("bLich")="CUC" then%>
				<td width="17%"><b><a style='text-decoration: none;color:blue' href="../leftmain.asp?bttlich=tcuc" target="main">Lịch của Cục</a></b></td>
			<%else%>
				<td width="17%"><b><a style='text-decoration: none;color:blue' href="../leftmain.asp?bttlich=cuc" target="main">Lịch của phòng</a></b></td>
			<%end if%>
		</tr>
			<center>
			<%
	     		  sSQL="SELECT * FROM dbo.Canbo WHERE     macanbo like '"& Session("bMaCB") &"' And (MONTH(GETDATE()) = MONTH(Ngaysinh)) AND (DAY(GETDATE()) = DAY(Ngaysinh))"
			  Set REcKTSN=Server.CreateObject("ADODB.Recordset")
			  REcKTSN.CursorType=3
			  REcKTSN.CacheSize=5
			  REcKTSN.Open sSQL,Conn
			  if REcKTSN.RecordCount then
			      Ngaysinh="yes"
			  else
			      Ngaysinh="no"
			  end if		
			  REcKTSN.Close
			  set REcKTSN	=nothing					  
			  %>
<!-- 			  <%if ngaysinh="yes" then%>
					<br>
			      <font color=blue size=3>Chúc mừng sinh nhật</Font>
			      <br><IMG SRC=birthday.gif>
			  <%end if%> -->
			  </center>
			<%
				' bg thphuc 20-02-03
				if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),"F39",1)="1" or Session("IsAdmin") then
					sSQL="select distinct flownode.maworkflow,workflow.tenvuviec,workflow.nguoitao,workflow.ngaytao,workflow.tentepxuly,workflow.Ngaytao from flownode inner join workflow on flownode.maworkflow=workflow.maworkflow where Trangthaixl<>2 And Trangthaixl<>-1 And Workflow.Tam<>1 And nguoixuly like '"& Session("bMaCB") &"' and flownode.trangthaixl in (0,1) order by workflow.ngaytao DESC"
				else
					sSQL="select distinct flownode.maworkflow,workflow.tenvuviec,workflow.nguoitao,workflow.ngaytao,workflow.tentepxuly,workflow.Ngaytao from flownode inner join workflow on flownode.maworkflow=workflow.maworkflow where Trangthaixl<>2 And Trangthaixl<>-1 And Workflow.Tam<>1 And nguoixuly like '"& Session("bMaCB") &"' and DATEDIFF(day,flownode.hanxuly,GETDATE())<=0 and flownode.trangthaixl in (0,1) order by workflow.ngaytao DESC"
				end if
				' ed thphuc 20-02-03
				Set RecKTXL=Server.CreateObject("ADODB.Recordset")
				REcKTXL.CursorType=3
				REcKTXL.CacheSize=5
				RecKTXL.Open sSQL,Conn
				if RecKTXL.RecordCount then
				    Xuly="yes"
				else
				    Xuly="no"
				end if		
				RecKTXL.Close
				set RecKTXL	=nothing
				' bg thphuc 21-02-03
				sSQL="select tenvuviec from  workflow where nguoitao like '"& Session("bMaCB") &"' and trangthai=0 and id in(select distinct workflow.id from workflow inner join flownode on workflow.maworkflow = flownode.maworkflow where flownode.trangthaixl = 2) order by ngaytao DESC"
				Set RecKtWorkflow=Server.CreateObject("ADODB.Recordset")
				RecKtWorkflow.CursorType=3
				RecKtWorkflow.CacheSize=5
				RecKtWorkflow.Open sSQL,Conn
				do while not RecKtWorkflow.eof
					if bNameWorkFlow="" then
						bNameWorkFlow=RecKtWorkflow("tenvuviec")
					else
						bNameWorkFlow=bNameWorkFlow + ", " + RecKtWorkflow("tenvuviec") 
					end if
					RecKtWorkflow.MoveNext
				loop
				RecKtWorkflow.Close
				set RecKtWorkflow	= nothing
				' ed thphuc 21-02-03
			%>
			<!-- bg thphuc 21-02-03 -->
			<%if Xuly="yes"  then%>
				<form name="frm" method="post">
					<table border=0 width="100%">
					<tr>
					<td width="80%" align="center"><font color=blue size=2><b>Ðồng chí có yêu cầu xử lý  </b></font></td>
					<td width="10%" ><Input type=button name=CmdXuly value="Xử lý" style='Font-family: Time New Roman;width:100%' LANGUAGE=javascript onclick="return CmdXuly_onclick()"></td><td width="10%"></td>
					</tr>
					<%if bNameWorkFlow <> "" then%>
						<tr>
						<td width="80%" align="center"><font color=blue size=2><b>Luồng xử lý <i><%=bNameWorkFlow%></i> đã hoàn thành</b></Font></td>
						<td width="10%" ><Input type=button name=CmdTheodoi value="Theo dõi" style='Font-family: Time New Roman;width:100%' LANGUAGE=javascript onclick="return CmdTheodoi_onclick()"></td><td width="10%"></td>
						</tr>
					<%end if%>
					</table>
				</form>
			<%else%>
				<%if bNameWorkFlow <> "" then%>
					<form name="frm" method="post">
					<table border=0 width="100%">
					<tr>
						<td width="80%" align="center"><font color=blue size=2><b>Luồng xử lý <i><%=bNameWorkFlow%></i> đã hoàn thành</b></Font></td>
						<td width="10%" ><Input type=button name=CmdTheodoi value="Theo dõi" style='Font-family: Time New Roman' LANGUAGE=javascript onclick="return CmdTheodoi_onclick()"></td><td width="10%"></td>
					</tr>
					</table>
					</form>
				<%end if%>
			<%end if%>
		<!-- ed thphuc 21-02-03 -->
<%end if%>
</BODY>
<SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>
function window_onload() {
	<%if Session("Started")="no" then %>
		Login.Username.focus();
		//Login.Username.value="admin";
		//Login.Password.value="123";
	<%end if%>
}
function CmdXuly_onclick()
{
	frm.action="../workflow/frmdsxuly.asp";
    frm.target="right";
    frm.submit();
}
function CmdTheodoi_onclick()
{
	frm.action="../workflow/frmdsflow.asp";
    frm.target="right";
    frm.submit();
}
</script>
</HTML>
<%
	Conn.Close
	Set Conn=nothing
%>